package factorytest.iflytek.com.einkiflytekfactorytest.common;

import android.content.Context;
import android.provider.Settings;
import android.util.Log;

import factorytest.iflytek.com.einkiflytekfactorytest.utils.DebugLog;

public class SettingsUtils {

    private final static int FT_TIME_SCREEN_OFF = 60 * 1000 * 15; //15 min

    public static void setScreenOffTimeForFT(Context context) {
        setScreenOffTime(context, FT_TIME_SCREEN_OFF);
    }

    public static void setScreenOffTime(Context context, int time_ms) {
        try {
            Settings.System.putInt(context.getContentResolver(),
                    "screen_off_timeout", time_ms);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void setBluetoothScoConnected(Context context, boolean connected) {

        try {

            DebugLog.e("setBluetoothScoConnected connected = " + connected);

            Settings.System.putInt(context.getContentResolver(), "device_mic_channel", connected ? 1 : 0);

        } catch (Exception e) {
            e.printStackTrace();
            DebugLog.e("setBluetoothScoConnected err = " + e.getMessage());
        }
    }
}
